﻿
System.Gadget.onDock = CheckDockState;
System.Gadget.onUndock = CheckDockState;

function CheckDockState()
{
    System.Gadget.beginTransition();

    var oBody = document.body.style;
    var oDocking = document.getElementById("gadgetContent").style;
    
    if (System.Gadget.docked)
    {
        oBody.width = 130;
        oBody.height = 117;
    } 
    
    else
    {
        oBody.width = 260;
        oBody.height = 234;  
    }

    System.Gadget.endTransition(System.Gadget.TransitionType.morph, 1);

    if (System.Gadget.docked) {
        oDocking.width = 120;
        oDocking.height = 92;

        size /= 2;
    }
    else {
        oDocking.width = 260 - 10;
        oDocking.height = 234 - 15;

        size *= 2;
    }
    
    SaveSettings();
    refresh();
}